import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsArray } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';
import { Type } from 'class-transformer';

export class BaseClockDto {
  @ApiProperty({ required: false, description: 'id' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  id?: number;

  @ApiProperty({ required: false, description: '用户ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  userId?: number;

  @ApiProperty({ required: false, description: '模板名称' })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiProperty({ required: false, description: '小时' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  hour?: number;

  @ApiProperty({ required: false, description: '分钟' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  minute?: number;

  @ApiProperty({ required: false, description: '重复日期（如“周一,周二,周三”）' })
  @IsOptional()
  @IsString()
  repeatDays?: string;

  @ApiProperty({ required: false, description: '是否每日重复，0为否，1为是' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  isDaily?: number;

  @ApiProperty({ required: false, description: '模板id' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  templateId?: number;

  @ApiProperty({ enum: CharEnum, required: false, description: '开启状态' })
  @IsOptional()
  @IsString()
  status?: string;

  @ApiProperty({ enum: CharEnum, required: false, description: '删除标志' })
  @IsOptional()
  @IsString()
  delFlag?: string;

  @ApiProperty({ required: false, description: '创建时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  createTime?: Array<string>;

  @ApiProperty({ required: false, description: '更新时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  updateTime?: Array<string>;
}

export class CreateClockDto extends OmitType(BaseClockDto, ['id', 'delFlag', 'createTime']) {}

export class UpdateClockDto extends OmitType(BaseClockDto, ['delFlag', 'createTime']) {}

export class QueryClockDto extends IntersectionType(BaseClockDto, PagingDto) {}

export class ListClockDto extends OmitType(BaseClockDto, ['delFlag', 'createTime', 'updateTime']) {}
